package model;

import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Host implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6081486797347771213L;
	String address;
	String alias;
	
	public Host(String address, String alias) {
		super();
		this.address = "http://"+address+":8080/chatAgentsEJB/NodeCommunication/NodeCommunicationBean?wsdl";
		if(alias != null){
			this.alias = alias;
		}else{
			try {
				this.alias=InetAddress.getLocalHost().getHostName();
			} catch (UnknownHostException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public Host() {
		super();
		try {
			//address=InetAddress.getLocalHost().getHostAddress();
			//address="192.168.0.100";
			alias=InetAddress.getLocalHost().getHostName();
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getAlias() {
		return alias;
	}
	public void setAlias(String alias) {
		this.alias = alias;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Host other = (Host) obj;
		if (address == null) {
			if (other.address != null)
				return false;
		} else if (!address.equals(other.address))
			return false;
		if (alias == null) {
			if (other.alias != null)
				return false;
		} else if (!alias.equals(other.alias))
			return false;
		return true;
	}
	@Override
	public String toString() {
		return "Host [address=" + address + ", alias=" + alias + "]";
	}
}
